package io.jt808.proto.req;

import io.norland.buffer.AutoBuffer;
import io.norland.annotations.Proto;
import io.norland.proto.IProto;
import lombok.Data;

/**
 * 电子运单上报
 */
@Proto("0701")
@Data
public class JT0701 implements IProto {
    private int waybillLength;
    private String waybill;

    public final byte[] writeToBytes() {
        AutoBuffer buffer = new AutoBuffer();
        buffer.writeInt(waybillLength);
        buffer.writeString(waybill, waybillLength);
        return buffer.array();
    }

    public final void readFromBuf(AutoBuffer buffer) {
        waybillLength = buffer.readInt();
        waybill = buffer.readString(waybillLength);
    }
}